/**
 * 公共部分 store
 */
import {
  getStoreList
} from '@/api/common.js'

import { setQCStoreList, getQCStoreList } from '@/libs/util'

export default {
  state: {
    storeList: getQCStoreList()
  },
  mutations: {
    setStoreList (state, info) {
      state.storeList = info
    }
  },
  getters: {
    shopList: state => state.storeList
  },
  actions: {
    // 店铺列表
    setStoreList ({ commit }, data) {
      return new Promise((resolve, reject) => {
        getStoreList({}).then(res => {
          resolve(res)
          setQCStoreList(res.data)
          commit('setStoreList', res.data)
        }).catch(err => {
          reject(err)
        })
      })
    }
  }
}
